<script setup lang="ts">
  import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';

  import { onHide, onLaunch, onShow } from '@dcloudio/uni-app';
  import {
    useMessage as useWotdMessage,
    useNotify as useWotdNotify,
    useToast as useWotdToast,
  } from 'wot-design-uni';

  import { setupMessage } from '@/hooks/useMessage';
  import { appSetup } from '@/logics/appSetup';

  const wotdToast = useWotdToast();
  const wotdNotify = useWotdNotify();
  const wotdMessage = useWotdMessage();

  setupMessage(wotdToast, wotdNotify, wotdMessage);

  // 当 uni-app 初始化完成时触发（全局只触发一次），参数为应用启动参数，同 uni.getLaunchOptionsSync 的返回值。
  onLaunch(async (_options) => {
    // console.log('App Launch', _options);
    try {
      // 应用设置
      await appSetup();
    } catch (err) {
      console.error('Launch', err);
    }
  });
  // 当 uni-app 启动，或从后台进入前台显示，参数为应用启动参数，同 uni.getLaunchOptionsSync 的返回值。
  onShow((_options) => {
    // console.log('App Show', options);
  });
  // 当 uni-app 从前台进入后台。
  onHide(() => {
    // console.log('App Hide');
  });
</script>

<style lang="scss">
  /*第三方动态库*/
  @import 'animate.css';
  /* stylelint-disable selector-type-no-unknown */
  button::after {
    border: none;
  }

  swiper,
  scroll-view {
    flex: 1;
    height: 100%;
    overflow: hidden;
  }

  image {
    width: 100%;
    height: 100%;
    vertical-align: middle;
  }

  // 单行省略，优先使用 unocss: text-ellipsis
  .ellipsis {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  // 两行省略
  .ellipsis-2 {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  // 三行省略
  .ellipsis-3 {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
  /* 主题设置 */
  page {
    // height: 100%;
    height: calc(100vh);
    // background: var(--theme-color);
  }
  /** wot-design-uni */
  .wd-cell__left {
    align-items: center;
  }
  /** 色弱 */
  .color-weak {
    filter: invert(80%);
  }
  /** 灰度 */
  .gray-mode {
    filter: grayscale(100%);
    filter: progid:dximagetransform.microsoft.basicimage(grayscale=1);
  }
</style>
